$(function() {

	/***************************************************************************
	 * 默认情况下全部收起左侧的菜单列表, 并且将是否展开左侧菜单的通过设置的方式存储在本地 localstorage 中
	 **************************************************************************/
	var key = 'left_menu_setting_localstorage';
	var theme = handleLocalStorage('get', key);
	if (theme) {
		// console.log(theme)
	}
	$(".left-nav-group>ul>li>a").each(function() {
		var _this = $(this);
		if (_this.hasClass("active")) {
			_this.parents("ul").prev("h2").click();
		}
	})
	$(".left-nav-group>ul>li>a").click(function() {
		var _this = $(this);
		for (var i = 0; i < $(".left-nav-group>ul>li>a").length; i++) {
			var item = $(".left-nav-group>ul>li>a")[i];
			if ($(item).hasClass("active")) {
				$(item).removeClass("active")
			}
		}
		_this.addClass("active");
		var src = _this.data("href").replace('{{time}}', new Date().getTime());
		if (src.indexOf("?") === -1) {
			src += ("?" + new Date().getTime())
		} else {
			if (src.lastIndexOf("time") === -1) {
				src += ("&time=" + new Date().getTime())
			} else {
				var pattern = /time=(\w+)/;
				var match = src.match(pattern);
				if (match[1]) {
					src = _this.data("href").replace(match[1], new Date().getTime());
				}
			}
		}

		$("#iframe-page").attr("src", src)
		iframeLoading()
	});
});

function iframeLoading() {
	$(".iframe-main").mLoading("show");
}

function iframeUnloading() {
	$(".iframe-main").mLoading("hide");
}

function iframeRedirectLogin(){
	window.location.href = "/login.html";
}